﻿namespace EasyCMS.Common.Querys
{
    using System;
    using Pismire;



    [System.Runtime.Serialization.DataContractAttribute(Name = "Partition", Namespace = "http://schemas.datacontract.org/2004/07/EasyCMS.Common.Querys")]
    public class Partition : Pismire.Querys.QueryBase
    {
        #region key
        /// <summary>
        /// 缓存键
        /// </summary>
        public override string Key
        {
            get { return string.Format(KeyFormat, DisplayName); }
        }
        private const string KeyFormat = "Partition_DisplayName{0}";
        #endregion

        #region DisplayName
        /// <summary>
        /// DisplayName
        /// </summary>
        public string DisplayName
        {
            get { return m_DisplayName; }
            set
            {
                m_DisplayName = value;
                this.HasDisplayName = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_DisplayName;
        public bool HasDisplayName { get; private set; }
        public bool DisplayNameIsLike { get; set; }
        public static ExcuteState DisplayName_Validate(ref string displayName)
        {
            return displayName.Validation("DisplayName").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref displayName).State;
        }
        #endregion

        #region checkMe
        /// <summary>
        /// 检查合法性
        /// </summary>
        /// <returns></returns>
        public override ExcuteState CheckMe()
        {
            //初始化
            ExcuteState state = null;

            state = DisplayName_Validate(ref this.m_DisplayName);
            if (!state.Succeed) return state;

            //返回
            return state;
        }
        #endregion
    }
}
